package com.aier.user.action;

import javax.servlet.http.Cookie;

import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;

import com.aier.common.common.CommonCookie;
import com.aier.common.common.CommonSession;
@Scope("prototype")
@Component("userLogoutAction")
public class UserLogoutAction extends UserBaseAction {

    
    /**
     * 
     */
    private static final long serialVersionUID = 1L;


    @Override
    public String execute(){
        //清除session
        session.remove(CommonSession.SESSION_ACCOUNT);
        session.remove(CommonSession.SESSION_ACCOUNT_ID);
        session.remove(CommonSession.SESSION_ACCOUNT_NAME);
        session.remove(CommonSession.SESSION_ACCOUNT_SCHOOLLIST);
        session.remove(CommonSession.SESSION_ACCOUNT_CLASSLIST);
        //清除cookie
        Cookie[] cookies = request.getCookies();
        if (cookies != null) {
            for (Cookie cookie : cookies) {
                if (CommonCookie.COOKIE_KEY_REMEMBER_LOGIN.equals(cookie.getName())
                        ||CommonCookie.COOKIE_KEY_PWD_LOGIN.equals(cookie.getName())) {
                    cookie.setValue("");
                    cookie.setMaxAge(0);
                }
            }
        }
        return SUCCESS;
    }



}
